package com.ysg.utils;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import java.util.Locale;

public class YPhoneUtil {


    /**
     * 获取手机型号
     */
    public static String getModel() {
        String model = Build.MODEL;
        if (YStringUtil.isEmpty(model)) {
            model = "android";
        }
        return model;
    }

    /**
     * 获取手机厂商
     */
    public static String getBrand() {
        return android.os.Build.BRAND;
    }

    /**
     * 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限)
     */
    public static String getIMEI(Context ctx) {
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);
        if (tm != null) {
            return tm.getDeviceId();
        }
        return null;
    }

    /**
     * 获取当前手机系统语言。
     */
    public static String getLanguage() {
        return Locale.getDefault().getLanguage();
    }

}
